#version 110

uniform vec4	LightPosition; // Light position in eye coords.

varying vec3	Dir;
varying vec3	Eye;
varying vec3	Norm;
varying vec3	Tang;
varying vec2	TexCoord;

uniform mat4	ModelMatrix;
uniform mat4	ViewMatrix;
uniform mat4	ProjectionMatrix;

attribute vec3	glTangent;

// Time: tt [seconds]
uniform float	GTime;	// Global

void main()
{
	TexCoord = gl_MultiTexCoord0.xy;
	mat4 toView = ViewMatrix * ModelMatrix;
	vec4 temp_pos = toView * gl_Vertex;

	vec3 Normal = normalize(vec3(toView * vec4(gl_Normal, 0.0)));
	vec3 Tangent = normalize(vec3(toView * vec4(glTangent, 0.0)));
	Dir = normalize(vec3(temp_pos - ViewMatrix * LightPosition));
	Eye = normalize(vec3(-temp_pos));
	Norm = Normal;
	Tang = Tangent;

	// add "underwater" visual effect =P
	//temp_pos.y += .05 * sin((GTime*5.0 + temp_pos.y) * 1.0);

	// Convert position to clip coordinates and pass along
	gl_Position = ProjectionMatrix * temp_pos; //ViewMatrix * ModelMatrix * temp_pos;
}
